package cz.spock.cms.entity;

import javax.persistence.Entity;
import javax.persistence.Id;

import com.google.appengine.api.blobstore.BlobKey;
import com.google.appengine.api.datastore.Blob;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Unindexed;

import cz.spock.core.entity.Account;

/**
 * BinaryDataHolder - used for persisting binary data
 * 
 * TODO test objectify and byte array - test problem with loading, maximum size of file, number of DB calls with big files
 * 
 * @author miso
 */
@Entity
public class BinaryDataHolder {
    
    @Id
    private Long id;
    
    private Key<Account> uploader;
    
    private String uri; // represents unique identification in human readable form ( /some/path/and/name )
    @Unindexed
    private String title; // not unique, title as short description of file
    @Unindexed
    private String description;
    @Unindexed
    private Blob datastoreData;
    @Unindexed
    private BlobKey blobstoreData;
    
    private String contentType;
    
    
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public String getUri() {
        return uri;
    }
    public void setUri(String uri) {
        this.uri = uri;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
    public Key<Account> getUploader() {
        return uploader;
    }
    public void setUploader(Key<Account> uploader) {
        this.uploader = uploader;
    }
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public String getContentType() {
        return contentType;
    }
    public void setContentType(String contentType) {
        this.contentType = contentType;
    }
    public Blob getDatastoreData() {
        return datastoreData;
    }
    public void setDatastoreData(Blob datastoreData) {
        this.datastoreData = datastoreData;
    }
    public BlobKey getBlobstoreData() {
        return blobstoreData;
    }
    public void setBlobstoreData(BlobKey blobstoreData) {
        this.blobstoreData = blobstoreData;
    }

}
